package com.ilop.sthome.ui.activity.mine;

import android.content.Intent;

import com.example.common.base.BaseBindActivity;
import com.example.common.utils.AppMarketUtil;
import com.ilop.sthome.common.CommonId;
import com.ilop.sthome.utils.ConfigureUtil;
import com.ilop.sthome.utils.system.AppUtil;
import com.siterwell.familywellplus.R;
import com.siterwell.familywellplus.databinding.ActivityAboutBinding;

/**
 * @author skygge
 * @date 2020-02-19.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：关于页面
 */
public class AboutActivity extends BaseBindActivity<ActivityAboutBinding> {

    private String privacy_agreement;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_about;
    }

    @Override
    protected void initView() {
        super.initView();
        String mVersionName = AppUtil.getVersionName(mContext);
        String version = getString(R.string.app_version_hint) + "\t\t" + mVersionName;
        boolean isDebug = AppUtil.isApkInDebug(mContext);
        if (isDebug){
            String finalVersion = version+ "." + AppUtil.getVersionCode(mContext);
            mDBind.appVersion.setText(finalVersion);
        }else {
            mDBind.appVersion.setText(version);
        }
    }

    @Override
    protected void initData() {
        super.initData();
        privacy_agreement = ConfigureUtil.getPrivacyAgreement(mContext);
    }

    @Override
    protected void initListener() {
        super.initListener();
        mDBind.ivAboutBack.setOnClickListener(view -> finish());

        mDBind.versionUpdate.setOnClickListener(view -> AppMarketUtil.gotoChinaMarket(this));

        mDBind.contactUs.setOnClickListener(view -> skipAnotherActivity(ContactUsActivity.class));

        mDBind.privacyAgree.setOnClickListener(view -> {
            Intent intent = new Intent();
            intent.setClass(mContext, WebViewActivity.class);
            intent.putExtra(CommonId.KEY_AGREEMENT, privacy_agreement);
            startActivity(intent);
        });

        mDBind.userAgree.setOnClickListener(view -> {
            Intent intent = new Intent();
            intent.setClass(mContext, AgreementActivity.class);
            startActivity(intent);
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

}
